package com.samapp.indent;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.samapp.R;
import com.samapp.entity.Samples;

public class SampleDetailAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private List<Samples> mSamples;

	public SampleDetailAdapter(Context context, List<Samples> mSamples) {
		this.mInflater = LayoutInflater.from(context);
		this.mSamples = mSamples;
	}

	@Override
	public int getCount() {
		return mSamples.size();
	}

	@Override
	public Object getItem(int position) {
		return mSamples.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.sample_details, parent, false);
			holder = new ViewHolder();
			holder.samplesCname = (TextView) convertView.findViewById(R.id.samples_cname);
			holder.samplesModel = (TextView) convertView.findViewById(R.id.samples_model);
			holder.samplesQty = (TextView) convertView.findViewById(R.id.samples_qty);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		Samples mySamples = mSamples.get(position);
		holder.samplesCname.setText(mySamples.getCname());
		holder.samplesModel.setText(mySamples.getModel());
		holder.samplesQty.setText(mySamples.getQty());
		return convertView;
	}

	private class ViewHolder {
		TextView samplesCname;
		TextView samplesModel;
		TextView samplesQty;
	}

}
